﻿'Params
'page (Optional) : The page number to fetch. Defaults to first page.
'limit (Optional) : The number of results to fetch per page. Defaults to 50.
'api_key (Required) : A Last.fm API key.
'Auth
'This service does not require authentication. 

Public Structure ChartGetTopTagsResponse
    Public tags() As Tag
End Structure


Public Class ChartGetTopTags
	Inherits BaseRequest
	Dim limit As String = ""
	Dim page As String = ""

	Public xmlresponse As XDocument = Nothing

	Public Sub New(limit As String, page As String)
		Me.limit = limit
		Me.page = page
	End Sub

	Public Sub sendRequest()
        InitializeMembers("chart.getTopTags")

		AddMember("limit", limit, False)
		AddMember("page", page, False)
		AddMember("api_key", My.Settings.api_key)

		xmlresponse = sendPOSTResponse()
	End Sub

    Public Function getResponse() As ChartGetTopTagsResponse
        Dim response As New ChartGetTopTagsResponse
        Dim count As Integer

        Try
            count = xmlresponse.<lfm>.<results>.<tracks>.Count()
        Catch ex As Exception
            Return response
        End Try

        If (count > 0) Then
            ReDim response.tags(count - 1)
            For i As Integer = 0 To count - 1
                response.tags(i) = New Tag(xmlresponse.<lfm>.<results>.<tags>(i))
            Next
        End If

        Return response
    End Function
End Class
